import request from "@/http/http"
import type { ApiResponse } from "@/http/http"

// 会议预约列表查询参数接口
export interface MeetingListParams {
    pageIndex: number      // 页码
    pageSize: number       // 每页大小
    RoomName?: string       // 会议名称
}

// 会议预约数据项类型
export interface MeetingItem {
    Id: number;
    Subject: string;
    MeetingRoomId: number;
    MeetingRoomName: string;
    HostId: string;
    HostName: string;
    MeetingDate: string;
    StartTime: string;
    EndTime: string;
    Participants: string;
    Content: string;
    RequireSignIn: boolean;
    AccessControlEnabled: boolean;
    SendSmsNotification: boolean;
    IsRemoteMeeting: boolean;
    Status: number;
}

// 会议预约列表响应数据结构
export interface MeetingListData {
    TotalCount: number;
    TotalPage: number;
    Data: MeetingItem[];
}

// 新增会议预约请求参数接口
export interface MeetingData {
    Id: number;
    Subject: string;
    MeetingRoomId: number;
    MeetingRoomName: string;
    HostId: string;
    HostName: string;
    MeetingDate: string;
    StartTime: string;
    EndTime: string;
    Participants: string;
    Content: string;
    RequireSignIn: boolean;
    AccessControlEnabled: boolean;
    SendSmsNotification: boolean;
    IsRemoteMeeting: boolean;
    Status: number;
}

// 更新会议预约请求参数接口
export interface UpdateMeetingParams {
    Id: number;
    Subject?: string;
    MeetingRoomId?: number;
    MeetingRoomName?: string;
    HostId?: string;
    HostName?: string;
    MeetingDate?: string;
    StartTime?: string;
    EndTime?: string;
    Participants?: string;
    Content?: string;
    RequireSignIn?: boolean;
    AccessControlEnabled?: boolean;
    SendSmsNotification?: boolean;
    IsRemoteMeeting?: boolean;
    Status?: number;
}

// 重新提交会议预约接口参数
export interface ResubmitMeetingParams {
    MeetingReservationId: number;
}

// 获取会议预约列表
export const getMeetingList = async (params: MeetingListParams): Promise<ApiResponse<MeetingListData>> => {
    return request({
        url: 'BaseDataReadAPI/MeetingReservation/GetReservationList',
        method: 'GET',
        params
    })
}

// 获取会议预约详情
export const getMeetingDetail = async (meetingId: number): Promise<ApiResponse<MeetingItem>> => {
    return request({
        url: 'BaseDataReadAPI/Meeting/GetMeetingDetail',
        method: 'GET',
        params: { meetingId }
    })
}

// 新增会议预约
export const addMeeting = async (data: MeetingData): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataWriteAPI/MeetingReservation/AddReservation',
        method: 'POST',
        data: data
    })
}

// 更新会议预约信息
export const updateMeeting = async (data: UpdateMeetingParams): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataWriteAPI/MeetingReservation/UpdateReservation',
        method: 'PUT',
        data: data
    })
}

// 删除会议预约
export const deleteMeeting = async (meetingId: number): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataWriteAPI/MeetingReservation/DeleteReservation',
        method: 'DELETE',
        params: { id:meetingId }
    })
}

// 批量删除会议预约
export const batchDeleteMeetings = async (meetingIds: number[]): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataWriteAPI/Meeting/BatchDeleteMeetings',
        method: 'DELETE',
        data: { meetingIds }
    })
}

// 获取会议模板列表
export const getMeetingTemplateList = async (): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataReadAPI/Meeting/GetMeetingTemplateList',
        method: 'GET'
    })
}

// 更新会议状态
export const updateMeetingStatus = async (meetingId: number, status: number): Promise<ApiResponse<any>> => {
    return request({
        url: 'BaseDataWriteAPI/Meeting/UpdateMeetingStatus',
        method: 'PUT',
        data: { meetingId, status }
    })
}

// 重新提交会议预约
export const resubmitMeeting = async (params: ResubmitMeetingParams): Promise<ApiResponse<any>> => {
    return request({
        url: 'MeetingApproval/ApprovalResubmit',
        method: 'POST',
        params
    })
} 